home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 17
/
CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso
/
CUCD
/
Online
/
TASC
/
rexx
/
AltSpam.thor
next >
Wrap
Text File
|
1997-09-26
|
11KB
|
438 lines
/* $VER: AltSpam.thor V0.5 (8/8/97)
* Takes an unsuccessful complaint & parses out the real & IP addresses to
* add to a file. This file can be used by TASC.thor to tell you when it's pointless
* to complain & to offer you an alternative address.
* Also gives you the option to resend your original complaint &
* request a traceroute.
*/
/*============Don't change anything below here==================*/
options results
options failat 31
/* Read the config file & set up defalts if it isn't there */
if open(cfg,'Env:thor/TASC.cfg',r) then do
do until eof(cfg)
lin=readln(cfg)
parse var lin id ':' V
V=strip(V)
if upper(left(id,6))='BOUNCE' then
Bounce=V
if upper(left(id,4))='MINE' then
Mine=V
if upper(left(id,10))='POSTMASTER' then
Postmaster=V
if upper(left(id,8))='DATABASE' then
spamdb=V
if upper(left(id,6))='TRACER' then
tracer=V
if upper(left(id,7))='TRACEFI' then
tracefi=V
if upper(left(id,8))='TRACETMP' then
tracetmp=V
end
call close(cfg)
end
else do
Bounce=''
Mine=''
Postmaster=''
spamdb='spam.db'
tracer='N'
tracetmp='traceroute.tmp'
tracefi='spamtrace.db'
end
FRM=''
failed.=''
spamfail.=''
email.=''
i=1
thorport = address()
if left(thorport, 5) ~= 'THOR.' then do
say 'Cannot find thorport.'
exit
end
if ~show('p', 'BBSREAD') then do
address command
"run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
"WaitForPort BBSREAD"
end
if open(A,'env:thor/thorpath') then do
THORP=READLN(A)
call close(A)
end
else do
address (thorport)
requestnotify text '"Unable to find/read env:thor/BBSdataPath"' BT '"_OK"'
exit
end
if open(T,'env:thor/BBSDataPath') then do
BBSP=READLN(T)
call close(T)
end
else do
address (thorport)
requestnotify text '"Unable to find/read env:thor/BBSdataPath"' BT '"_OK"'
exit
end
address(thorport)
CURRENTMSG stem MSG
if (rc ~= 0) then call oops("No current message.")
SAVEMESSAGE CURRENT FILE "T:AltSpam.temp"
if(rc ~= 0) then call oops("Unable to save current message.")
IF Open(A,'T:Altspam.temp','r') = 0 THEN DO
call oops("Couldn't open temporary file")
EXIT 20
END
do until index(hder,'X-Mailer: THOR')~=0
/* A header line belonging to Thor. We assume that no one runs their
mailserver with Thor */
hder= readln(A)
if upper(left(hder,5))='FROM:' then do
Call FRM
end
if upper(left(hder,3))='TO:' then do
Call TOHDR
end
if upper(left(hder,9))='ORIGINAL-' then do
Call ORIG
end
if upper(left(hder,6))='FINAL-' then do
Call FIN
end
end
do until upper(left(hder,9))='RECEIVED:' | eof(A)
hder=readln(A)
end
rl=0
rcd.rl=hder
fwarn=':'
do until hder='' | eof(A)
hder=readln(A)
if upper(left(hder,8))='RECEIVED' then do
rl=1-rl
rcd.rl=hder
end
end
close(A)
/* Now ask what we should do the next time that we meet these addresses */
if open(A,BBSP||'db/'||spamdb,'r') then do
DO WHILE ~Eof(A)
f=readln(A)
parse VAR f wrong '->' correct
do j=1 to spamfail.count
parse VAR spamfail.j gubbins ':' addr
if wrong=addr then do
spamfail.j=''
if upper(correct)='FAKED' & faked~='Y' then do
rl=1-rl
fwarn='(Not faked):'
fake='Y'
end
end
end
END
end
a=1
do j=1 to spamfail.count
if spamfail.j~='' then do
failed.a=spamfail.j
a=a+1
end
end
failed.count=a-1
if failed.count<1 then call oops("All addresses are assigned already.\n Try editing the "||BBSP||'db/'||spamdb||" file by hand.")
drop spamfail.
address(Thorport)
Requestlist Instem failed outstem spamfail dragselect multiselect title '"Add which addresses?"'
IF (RC > 0) THEN do
Call NewTr
call cleanup
end
do i=1 to failed.count
parse VAR failed.i gubbins ':' failed.i
end
do i=1 to spamfail.count
parse VAR spamfail.i gubbins ':' spamfail.i
end
k=3
do i=1 to spamfail.count
drop email.
email.1='Mark as Undeliverable'
email.2='Faked address in last Received line'
email.count=2
if FRM~='' then do
email.k=FRM
k=k+1
end
Call ParseAlt
email.count=k-1
Call Recd
Call PickAlt
call Remail
if upper(tracer)='Y' then Call newTR
end
call cleanup
FRM:
if index(hder,mine)=0 then do
parse VAR hder gubbins '@' FRM
FRM=strip(FRM,'T',' .)>')
end
return
TOHDR:
parse VAR hder gubbins '@' TOHDR
TOHDR=strip(TOHDR,'T',' .>)')
if TOHDR=Bounce then return
if TOHDR=mine then return
if index(TOHDR,',')~=0 then do until index(TOHDR,',')=0
parse VAR TOHDR tohd ',' pm '@' TOHDR
spamfail.i='[TO Postmaster@ ]:'||tohd
i=i+1
end
spamfail.i='[TO Postmaster@ ]:'||TOHDR
spamfail.count=i
i=i+1
return
ORIG:
parse VAR hder gubbins ';' pm '@' ORIG
spamfail.i='[Original-Recipient]:'||ORIG
spamfail.count=i
i=i+1
return
FIN:
parse VAR hder gubbins ';' pm '@' FIN
spamfail.i='[Final-Recipient ]:'||FIN
spamfail.count=i
i=i+1
return
ParseAlt:
if left(spamfail.i,1)='[' then do
do j=1 to failed.count
if left(failed.j,1)~='[' then do
baseaddr=failed.j
Call parseaddr
parsed='Y'
end
end
if parsed~='Y' then do
email.k='No other alternative addresses in the bounce message'
k=k+1
end
end
else do
baseaddr=spamfail.i
Call Parseaddr
end
if upper(tracer)='Y' then do
if open(trdb,BBSP||'db/'||tracefi)then do until eof(trdb)
trl=readln(trdb)
if index(trl,spamfail.i)~=0 then do until trl='Done'
trl=readln(trdb)
parse VAR trl tr 'ms'
parse VAR tr ' ' tr ' '
if tr~='' & left(tr,5)~='* * *' then do
tr=strip(tr,'L',' *')
email.k='#'||tr
k=k+1
end
end
end
end
return
Parseaddr:
email.k=baseaddr
k=k+1
do until index(baseaddr,'.')=0
parse VAR baseaddr lwr '.' hghr
if index(hghr,'.')~=0 then do
email.k=hghr
k=k+1
end
baseaddr=hghr
end
return
PickAlt:
newaddr.=''
Requestlist Instem email outstem newaddr title '"Substitute which address for '||spamfail.i||'?"'
IF (RC > 0) THEN DO
REQUESTNOTIFY TEXT '"No Addresses Selected"' BT '"_Ok"'
return
END
newaddr=result
if left(newaddr,1)='#' then do
newaddr=strip(newaddr,'L','#')
address (thorport)
requestnotify text '"Use which part of '||newaddr '"' BT '"_Text|_IP"'
if result=0 then do /*IP*/
parse VAR newaddr '(' newaddr ')'
newaddr='['||newaddr||']'
end
else do
parse VAR newaddr newaddr '('
end
end
if newaddr='No other alternative addresses in the bounce message' then
return
if newaddr='Mark as Undeliverable' then
newaddr='Undeliverable'
if newaddr='Faked address in last Received line' then
newaddr='Faked'
address command
'echo '||spamfail.i||'->'||newaddr||' >> '||BBSP||'db/'||spamdb
return
Recd:
parse VAR rcd.rl gubbins 'from' addss 'by' remains
parse VAR addss rnme '(' brak ')'
if index(rnme,'[')~=0 then do
parse VAR rnme rnme '[' brak
end
netnum=brak
if index(brak,'(')~=0 then do
parse VAR brak xtra '(' netnum ')'
end
if index(brak,'[')~=0 then do
parse VAR brak xtra '[' netnum ']'
end
if index(brak,'@')~=0 then do
parse VAR brak gubbins '@' remains
if index(remains,'[')~=0 then do
parse VAR remains xtra '[' gubbins
end
if index(remains,'(')~=0 then do
parse VAR remains xtra '(' gubbins
end
if index(remains,' ')~=0 then do
parse VAR remains xtra ' ' gubbins
end
end
if (rnme~='RNME' & rnme~='') then do
m=(email.count)+1
email.m='[Mailserver]'||fwarn||strip(rnme,'B','.]) ')
email.count=m
end
if (netnum~='NETNUM' & netnum~='') then do
m=(email.count)+1
email.m='[Mailserver]'||fwarn||'['||strip(netnum,'B','.]) ')||']'
email.count=m
end
if (xtra~='XTRA' & xtra~='') then do
m=(email.count)+1
email.m='[Mailserver]'||fwarn||strip(xtra,'B','.]) ')
email.count=m
end
return
Remail:
address(thorport)
if newaddr='Undeliverable' | newaddr='Faked' | newaddr='NEWADDR' then return
if newaddr~=spamfail.i then do
adder='Remail complaint to '||newaddr||' (was '||spamfail.i||')?'
requestnotify text '"' adder '"' BT '"_Yes|_No"'
if result=0 then return
if open(A,'T:altspam.temp','r')>0 then do
hder=readln(A)
do until index(hder,'X-Mailer: THOR')~=0
hder=readln(A)
end
CURRENTMSG stem MSG
address bbsread
UNIQUEMSGFILE bbsname '"'MSG.BBSNAME'"' stem tmp
if (rc ~= 0) then call oops
if open(B,tmp.NAME,'w')>0 then do
if Postmaster~='' then do
call Writeln(B,'"From: postmaster@'||Postmaster||'"')
call Writeln(B,"")
end
do until eof(A)
hder=readln(A)
writeln(B,hder)
end
call close(B)
end
call close(A)
end
EVE_ENTERMSG = 0
drop EVENT.
EVENT.TONAME = 'Postmaster'
EVENT.TOADDR = 'Postmaster@'||newaddr
EVENT.SUBJECT = 'Spam/Email abuse'
EVENT.CONFERENCE = 'EMail'
EVENT.MSGFILE = tmp.FILEPART
EVENT.URGENT = 0
WRITEBREVENT bbsname '"'MSG.BBSNAME'"' event EVE_ENTERMSG stem EVENT
end
return
NewTR:
/* Gives the option to request a traceroute for any of the addresses */
address (thorport)
Requestlist Instem email outstem route dragselect multiselect title '"Send tracceroute requests for:"'
if rc=0 then do
Call Tr
end
return
Tr:
do j=1 to route.count
address command
route.j=strip(route.j,L,'*#')
if route.j='No alternative addresses'| route.j='Mark as Undeliverable' | route.j='Faked address in last Received line' then do
NOP
end
else do
if index(route.j,'(')~=0 then do
parse VAR route.j '(' route.j ')'
route.j='['||route.j||']'
end
'echo "echo Finding route for: '||addr||' >> '||BBSP||'db/'||tracefi||'" >> '||BBSP||tracetmp
'echo "traceroute '||addr||' >> '||BBSP||'db/'||tracefi||'" >> '||BBSP||tracetmp
'echo "echo Done" >> '||BBSP||'db/'||tracefi||' >> '||BBSP||tracetmp
end
end
'protect '||BBSP||tracetmp||' +s'
return
return
oops:
PARSE ARG errmsg
if errmsg = '' then do
if address() = "BBSREAD" then errmsg=BBSREAD.LASTERROR
else errmsg=THOR.LASTERROR
end
address(thorport)
REQUESTNOTIFY TEXT '"' errmsg '"' BT '"_Abort"'
call cleanup
return
cleanup:
address command 'delete >nil: T:AltSpam.temp'
exit